package com.ruoyi.web.controller.market.sys;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AuthItemInfo;
import com.ruoyi.sys.service.IAuthItemInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.AuthItemInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实名子项值Controller
 * 
 * @author ruoyi
 * @date 2023-03-07
 */
@Controller
@RequestMapping("/auth/itemInfo")
public class AuthItemInfoController extends BaseController
{
    private String prefix = "auth/itemInfo";

    @Autowired
    private IAuthItemInfoService authItemInfoService;

    @RequiresPermissions("auth:itemInfo:view")
    @GetMapping()
    public String itemInfo()
    {
        return prefix + "/itemInfo";
    }

    /**
     * 查询实名子项值列表
     */
    @RequiresPermissions("auth:itemInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AuthItemInfo authItemInfo)
    {
        startPage();
        List<Map<String, Object>> mapList = authItemInfoService.selectAuthItemInfoListMap(authItemInfo);
        mapList = new AuthItemInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出实名子项值列表
     */
    @RequiresPermissions("auth:itemInfo:export")
    @Log(title = "实名子项值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AuthItemInfo authItemInfo)
    {
        List<AuthItemInfo> list = authItemInfoService.selectAuthItemInfoList(authItemInfo);
        ExcelUtil<AuthItemInfo> util = new ExcelUtil<AuthItemInfo>(AuthItemInfo.class);
        return util.exportExcel(list, "实名子项值数据");
    }

    /**
     * 新增实名子项值
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存实名子项值
     */
    @RequiresPermissions("auth:itemInfo:add")
    @Log(title = "实名子项值", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AuthItemInfo authItemInfo)
    {
        return toAjax(authItemInfoService.insertAuthItemInfo(authItemInfo));
    }

    /**
     * 修改实名子项值
     */
    @RequiresPermissions("auth:itemInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AuthItemInfo authItemInfo = authItemInfoService.selectAuthItemInfoById(id);
        mmap.put("authItemInfo", authItemInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存实名子项值
     */
    @RequiresPermissions("auth:itemInfo:edit")
    @Log(title = "实名子项值", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AuthItemInfo authItemInfo)
    {
        return toAjax(authItemInfoService.updateAuthItemInfo(authItemInfo));
    }

    /**
     * 删除实名子项值
     */
    @RequiresPermissions("auth:itemInfo:remove")
    @Log(title = "实名子项值", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(authItemInfoService.deleteAuthItemInfoByIds(ids));
    }
}
